#ifndef HASPTR_H
#define HASPTR_H

#include <string>

class Hasptr
{
private:
    std::string *ps;
    int i;
public:
    Hasptr(const std::string &s = std::string()) : 
           ps(new std::string(s)), i(0) { }
    Hasptr(const Hasptr &p) : 
           ps(new std::string(*p.ps)), i(p.i) { }
    Hasptr& operator = (const Hasptr &);
    ~Hasptr() { delete ps; }
};
/**
 * @brief Destroy the Hasptr:: Hasptr object
 * 
 */
Hasptr::~Hasptr()
{
}
/**
 * @brief 
 * 
 * @param rhs 
 * @return Hasptr& 
 */
Hasptr& Hasptr::operator = (const Hasptr &rhs)
{
    auto newp = new std::string(*rhs.ps); // 拷贝底层 string
    delete ps; // 释放旧内存
    ps = newp; // 从右侧运算对象拷贝数据到本对象
    i = rhs.i;
    return *this; // 返回本对象
}
#endif